package com.yuexi.domain.util;

import org.springframework.core.io.FileSystemResource;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

/**
 * @author jie
 * @date 2023/4/10 -13:03
 */
public class IOUtilsEx extends org.apache.commons.io.IOUtils {

    public static String readFileToString(String fileSystemPath) {
        FileSystemResource fileSystemResource = new FileSystemResource(fileSystemPath);
        try {
            InputStream inputStream = fileSystemResource.getInputStream();
            return org.apache.commons.io.IOUtils.toString(inputStream, StandardCharsets.UTF_8);
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage());
        }
    }
}
